import { defineStore } from 'pinia'

export const useBbListStore = defineStore('bbList', {
  state: () => ({
    items: [
      {
        name: '',
        des: '芙蓉仙子001',
        jnList: [],
      },
    ],
    index: 0,
  }),
  getters: {
    currentBb: (state) => {
      console.log('currentBb', state.index, state.items[state.index].des, Array.from(state.items[state.index].jnList))
      return state.items[state.index]
    },
  },
  actions: {
    save({ jnList }) {
      this.items[0] = {
        ...this.items[0],
        jnList,
      }
    },
    add({ jnList }) {
      this.items.push({
        des: `芙蓉仙子00${this.items.length + 1}`,
        jnList,
      })
      setTimeout(() => {
        
      }, 1000);
    },
    clear() {
      this.items = [
        {
          name: '',
          des: '芙蓉仙子001',
          jnList: [],
        },
      ]
      this.index = 0
    },
  },
})
